<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

  <div id="app"></div>
  
  <script src="../react-js/react.development.js" crossorigin></script>
  <script src="../react-js/react-dom.development.js" crossorigin></script>
  <script src="../react-js/babel.min.js"></script>

  <script type="text/babel">
    class App extends React.Component {
      constructor() {
        super()

        this.state = {
          counter: 0
        }
      }

      render() {
        return (
          <div>
            <h2>当前计数 { this.state.counter } </h2>
            <button onClick={ this.increment.bind(this) }>+1</button>  
            <button onClick={ this.decrement.bind(this) }>-1</button>  
          </div>
        )
      }

      increment() {
        this.setState({
          counter: this.state.counter + 1
        })
      }

      decrement() {
        this.setState({
          counter: this.state.counter - 1
        })
      }

    }

    ReactDOM.render(<App/>, document.getElementById('app'))
  </script>
</body>
</html>